home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / OpenGL / OPENGL2.EXE / _SETUP.1 / paletted_texture.spec < prev    next >
Encoding:
Text File  |  1997-10-31  |  18.9 KB  |  433 lines

  1. Name
  2.  
  3.     EXT_paletted_texture
  4.  
  5. Name Strings
  6.  
  7.     GL_EXT_paletted_texture
  8.  
  9. Version
  10.  
  11.     $Date: 1997/07/22 21:01:04 $ $Revision: 1.1 $
  12.  
  13. Number
  14.  
  15.     78
  16.  
  17. Dependencies
  18.  
  19.     GL_EXT_paletted_texture shares routines and enumerants with
  20.     GL_SGI_color_table with the minor modification that EXT replaces SGI.
  21.     In all other ways these calls should function in the same manner and the
  22.     enumerant values should be identical.  The portions of
  23.     GL_SGI_color_table that are used are:
  24.         ColorTableSGI, GetColorTableSGI, GetColorTableParameterivSGI, 
  25.         GetColorTableParameterfvSGI.
  26.         COLOR_TABLE_FORMAT_SGI, COLOR_TABLE_WIDTH_SGI,
  27.             COLOR_TABLE_RED_SIZE_SGI, COLOR_TABLE_GREEN_SIZE_SGI,
  28.             COLOR_TABLE_BLUE_SIZE_SGI, COLOR_TABLE_ALPHA_SIZE_SGI,
  29.             COLOR_TABLE_LUMINANCE_SIZE_SGI, COLOR_TABLE_INTENSITY_SIZE_SGI.
  30.  
  31.     Portions of GL_SGI_color_table which are not used in
  32.     GL_EXT_paletted_texture are:
  33.         CopyColorTableSGI, ColorTableParameterivSGI,
  34.             ColorTableParameterfvSGI.
  35.         COLOR_TABLE_SGI, POST_CONVOLUTION_COLOR_TABLE_SGI,
  36.             POST_COLOR_MATRIX_COLOR_TABLE_SGI, PROXY_COLOR_TABLE_SGI,
  37.             PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI,
  38.             PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI, COLOR_TABLE_SCALE_SGI,
  39.             COLOR_TABLE_BIAS_SGI.
  40.  
  41.     EXT_paletted_texture can be used in conjunction with EXT_texture3D.
  42.     EXT_paletted_texture modifies TexImage3DEXT to accept paletted image
  43.     data and allows TEXTURE_3D_EXT and PROXY_TEXTURE_3D_EXT to be used a
  44.     targets in the color table routines.  If EXT_texture3D is unsupported
  45.     then references to 3D texture support in this spec are invalid and
  46.     should be ignored.
  47.  
  48. Overview
  49.     
  50.     EXT_paletted_texture defines new texture formats and new calls to
  51.     support the use of paletted textures in OpenGL.  A paletted texture is
  52.     defined by giving both a palette of colors and a set of image data which
  53.     is composed of indices into the palette.  The paletted texture cannot
  54.     function properly without both pieces of information so it increases the
  55.     work required to define a texture.  This is offset by the fact that the
  56.     overall amount of texture data can be reduced dramatically by factoring
  57.     redundant information out of the logical view of the texture and placing
  58.     it in the palette.
  59.     
  60.     Paletted textures provide several advantages over full-color textures:
  61.  
  62.     * As mentioned above, the amount of data required to define a
  63.     texture can be greatly reduced over what would be needed for full-color
  64.     specification.  For example, consider a source texture that has only 256
  65.     distinct colors in a 256 by 256 pixel grid.  Full-color representation
  66.     requires three bytes per pixel, taking 192K of texture data.  By putting
  67.     the distinct colors in a palette only eight bits are required per pixel,
  68.     reducing the 192K to 64K plus 768 bytes for the palette.  Now add an
  69.     alpha channel to the texture.  The full-color representation increases
  70.     by 64K while the paletted version would only increase by 256 bytes.
  71.     This reduction in space required is particularly important for hardware
  72.     accelerators where texture space is limited.
  73.  
  74.     * Paletted textures allow easy reuse of texture data for images
  75.     which require many similar but slightly different colored objects.
  76.     Consider a driving simulation with heavy traffic on the road.  Many of
  77.     the cars will be similar but with different color schemes.  If
  78.     full-color textures are used a separate texture would be needed for each
  79.     color scheme, while paletted textures allow the same basic index data to
  80.     be reused for each car, with a different palette to change the final
  81.     colors.
  82.  
  83.     * Paletted textures also allow use of all the palette tricks
  84.     developed for paletted displays.  Simple animation can be done, along
  85.     with strobing, glowing and other palette-cycling effects.  All of these
  86.     techniques can enhance the visual richness of a scene with very little
  87.     data.
  88.  
  89. New Procedures and Functions
  90.  
  91.     void ColorTableEXT(
  92.     enum target,
  93.     enum internalFormat,
  94.     sizei width,
  95.     enum format,
  96.     enum type,
  97.     const void *data);
  98.  
  99.     void ColorSubTableEXT(
  100.     enum target,
  101.     sizei start,
  102.     sizei count,
  103.     enum format,
  104.     enum type,
  105.     const void *data);
  106.  
  107.     void GetColorTableEXT(
  108.     enum target,
  109.     enum format,
  110.     enum type,
  111.     void *data);
  112.  
  113.     void GetColorTableParameterivEXT(
  114.     enum target,
  115.     enum pname,
  116.     int *params);
  117.  
  118.     void GetColorTableParameterfvEXT(
  119.     enum target,
  120.     enum pname,
  121.     float *params);
  122.  
  123. New Tokens
  124.  
  125.     Accepted by the internalformat parameter of TexImage1D, TexImage2D and
  126.     TexImage3DEXT:
  127.     COLOR_INDEX1_EXT        0x80E2
  128.     COLOR_INDEX2_EXT        0x80E3
  129.     COLOR_INDEX4_EXT        0x80E4
  130.     COLOR_INDEX8_EXT        0x80E5
  131.     COLOR_INDEX12_EXT        0x80E6
  132.     COLOR_INDEX16_EXT        0x80E7
  133.  
  134.     Accepted by the pname parameter of GetColorTableParameterivEXT and
  135.     GetColorTableParameterfvEXT:
  136.     COLOR_TABLE_FORMAT_EXT        0x80D8
  137.     COLOR_TABLE_WIDTH_EXT        0x80D9
  138.     COLOR_TABLE_RED_SIZE_EXT    0x80DA
  139.     COLOR_TABLE_GREEN_SIZE_EXT    0x80DB
  140.     COLOR_TABLE_BLUE_SIZE_EXT    0x80DC
  141.     COLOR_TABLE_ALPHA_SIZE_EXT    0x80DD
  142.     COLOR_TABLE_LUMINANCE_SIZE_EXT    0x80DE
  143.     COLOR_TABLE_INTENSITY_SIZE_EXT    0x80DF
  144.  
  145.     Accepted by the value parameter of GetTexLevelParameter{if}v:
  146.     TEXTURE_INDEX_SIZE_EXT        0x80ED
  147.  
  148. Additions to Chapter 2 of the GL Specification (OpenGL Operation)
  149.  
  150. None
  151.  
  152. Additions to Chapter 3 of the GL Specification (Rasterization)
  153.  
  154.   Section 3.6.4, 'Pixel Transfer Operations,' subsection 'Color Index
  155.   Lookup,' 
  156.  
  157.     Point two is modified from 'The groups will be loaded as an
  158.     image into texture memory' to 'The groups will be loaded as an image
  159.     into texture memory and the internalformat parameter is not one of the
  160.     color index formats from table 3.8.'
  161.  
  162.   Section 3.8, 'Texturing,' subsection 'Texture Image Specification' is
  163.   modified as follows:
  164.  
  165.     The portion of the first paragraph discussing interpretation of format,
  166.     type and data is split from the portion discussing target, width and
  167.     height.  The target, width and height section now ends with the sentence
  168.     'Arguments width and height specify the image's width and height.'
  169.     
  170.     The format, type and data section is moved under a subheader 'Direct
  171.     Color Texture Formats' and begins with 'If internalformat is not one of
  172.     the color index formats from table 3.8,' and continues with the existing
  173.     text through the internalformat discussion.
  174.  
  175.     After that section, a new section 'Paletted Texture Formats' has the
  176.     text:
  177.       If format is given as COLOR_INDEX then the image data is
  178.       composed of integer values representing indices into a table of colors
  179.       rather than colors themselves.  If internalformat is given as one of the
  180.       color index formats from table 3.8 then the texture will be stored
  181.       internally as indices rather than undergoing index-to-RGBA mapping as
  182.       would previously have occurred.  In this case the only valid values for
  183.       type are BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT and
  184.       UNSIGNED_INT.
  185.  
  186.       The image data is unpacked from memory exactly as for a
  187.       DrawPixels command with format of COLOR_INDEX for a context in color
  188.       index mode.  The data is then stored in an internal format derived from
  189.       internalformat.  In this case the only legal values of internalformat
  190.       are COLOR_INDEX1_EXT, COLOR_INDEX2_EXT, COLOR_INDEX4_EXT,
  191.       COLOR_INDEX8_EXT, COLOR_INDEX12_EXT and COLOR_INDEX16_EXT and the
  192.       internal component resolution is picked according to the index
  193.       resolution specified by internalformat.  Any excess precision in the
  194.       data is silently truncated to fit in the internal component precision.
  195.   
  196.       An application can determine whether a particular
  197.       implementation supports a particular paletted format (or any paletted
  198.       formats at all) by attempting to use the paletted format with a proxy
  199.       target.  TEXTURE_INDEX_SIZE_EXT will be zero if the implementation
  200.       cannot support the texture as given.
  201.  
  202.       An application can determine an implementation's desired
  203.       format for a particular paletted texture by making a TexImage call with
  204.       COLOR_INDEX as the internalformat, in which case target must be a proxy
  205.       target.  After the call the application can query
  206.       TEXTURE_INTERNAL_FORMAT to determine what internal format the
  207.       implementation suggests for the texture image parameters.
  208.       TEXTURE_INDEX_SIZE_EXT can be queried after such a call to determine the
  209.       suggested index resolution numerically.  The index resolution suggested
  210.       by the implementation does not have to be as large as the input data
  211.       precision.  The resolution may also be zero if the implementation is
  212.       unable to support any paletted format for the given texture image.
  213.     
  214.     Table 3.8  should be augmented with a column titled 'Index bits.'  All
  215.     existing formats have zero index bits.  The following formats are added
  216.     with zeroes in all existing columns:
  217.         Name                Index bits
  218.         COLOR_INDEX1_EXT        1
  219.         COLOR_INDEX2_EXT        2
  220.         COLOR_INDEX4_EXT        4
  221.         COLOR_INDEX8_EXT        8
  222.         COLOR_INDEX12_EXT        12
  223.         COLOR_INDEX16_EXT        16
  224.  
  225.     At the end of the discussion of level the following text should be
  226.     added:
  227.  
  228.       All mipmapping levels share the same palette.  If levels
  229.       are created with different precision indices then their internal formats
  230.       will not match and the texture will be inconsistent, as discussed above.
  231.     
  232.     In the discussion of internalformat for CopyTexImage{12}D, at end of the
  233.     sentence specifying that 1, 2, 3 and 4 are illegal there should also be
  234.     a mention that paletted internalformat values are illegal.
  235.     
  236.     At the end of the width, height, format, type and data section under
  237.     TexSubImage there should be an additional sentence:
  238.  
  239.       If the target texture has an color index internal format
  240.       then format may only be COLOR_INDEX.
  241.  
  242.     At the end of the first paragraph describing TexSubImage and
  243.     CopyTexSubImage the following sentence should be added:
  244.  
  245.       If the target of a CopyTexSubImage is a paletted texture
  246.       image then INVALID_OPERATION is returned.
  247.  
  248.     After the Alternate Image Specification Commands section, a new 'Palette
  249.     Specification Commands' section should be added.
  250.  
  251.       Paletted textures require palette information to
  252.       translate indices into full colors.  The command
  253.     void ColorTableEXT(enum target, enum internalformat, sizei width, 
  254.         enum format, enum type, const void *data);
  255.       is used to specify the format and size of the palette
  256.       for paletted textures.  target specifies which texture is to have its
  257.       palette changed and may be one of TEXTURE_1D, TEXTURE_2D,
  258.       PROXY_TEXTURE_1D, PROXY_TEXTURE_2D, TEXTURE_3D_EXT or
  259.       PROXY_TEXTURE_3D_EXT.  internalformat specifies the desired format and
  260.       resolution of the palette when in its internal form.  internalformat can
  261.       be any of the non-index values legal for TexImage internalformat
  262.       although implementations are not required to support palettes of all
  263.       possible formats.  width controls the size of the palette and must be a
  264.       power of two greater than or equal to one.  format and type specify the
  265.       number of components and type of the data given by data.  format can be
  266.       any of the formats legal for DrawPixels although implementations are not
  267.       required to support all possible formats.  type can be any of the types
  268.       legal for DrawPixels except GL_BITMAP.
  269.  
  270.       Data is taken from memory and converted just as if each
  271.       palette entry were a single pixel of a 1D texture.  Pixel unpacking and
  272.       transfer modes apply just as with texture data.  After unpacking and
  273.       conversion the data is translated into a internal format that matches
  274.       the given format as closely as possible.  An implementation does not,
  275.       however, have a responsibility to support more than one precision for
  276.       the base formats.
  277.  
  278.       If the palette's width is greater than than the range of
  279.       the color indices in the texture data then some of the palettes entries
  280.       will be unused.  If the palette's width is less than the range of the
  281.       color indices in the texture data then the most-significant bits of the
  282.       texture data are ignored and only the appropriate number of bits of the
  283.       index are used when accessing the palette.
  284.  
  285.       Specifying a proxy target causes the proxy texture's
  286.       palette to be resized and its parameters set but no data is transferred
  287.       or accessed.  If an implementation cannot handle the palette data given
  288.       in the call then the color table width and component resolutions are set
  289.       to zero.
  290.  
  291.       Portions of the current palette can be replaced with
  292.     void ColorSubTableEXT(enum target, sizei start, sizei count, 
  293.         enum format, enum type, const void *data);
  294.       target can be any of the non-proxy values legal for
  295.       ColorTableEXT.  start and count control which entries of the palette are
  296.       changed out of the range allowed by the internal format used for the
  297.       palette indices.  count is silently clamped so that all modified entries
  298.       all within the legal range.  format and type can be any of the values
  299.       legal for ColorTableEXT.  The data is treated as a 1D texture just as in
  300.       ColorTableEXT.
  301.  
  302.     In the 'Texture State and Proxy State' section the sentence fragment
  303.     beginning 'six integer values describing the resolutions...' should be
  304.     changed to refer to seven integer values, with the seventh being the
  305.     index resolution.
  306.  
  307.     Palette data should be added in as a third category of texture state.
  308.  
  309.     After the discussion of properties, the following should be added:
  310.  
  311.       Next there is the texture palette.  All textures have a
  312.       palette, even if their internal format is not color index.  A texture's
  313.       palette is initially one RGBA element with all four components set to
  314.       1.0.
  315.  
  316.     The sentence mentioning that proxies do not have image data or
  317.     properties should be extended with 'or palettes.'
  318.  
  319.     The sentence beginning 'If the texture array is too large' describing
  320.     the effects of proxy failure should change to read:
  321.  
  322.       If the implementation is unable to handle the texture
  323.       image data the proxy width, height, border width and component
  324.       resolutions are set to zero.  This situation can occur when the texture
  325.       array is too large or an unsupported paletted format was requested.
  326.  
  327. Additions to Chapter 4 of the GL Specification (Per-Fragment Operations
  328. and the Framebuffer)
  329.  
  330. None
  331.  
  332. Additions to Chapter 5 of the GL Specification (Special Functions)
  333.  
  334. None
  335.  
  336. Additions to Chapter 6 of the GL Specification (State and State
  337. Requests)
  338.  
  339.     In the section on GetTexImage, the sentence saying 'The components are
  340.     assigned among R, G, B and A according to' should be changed to be
  341.  
  342.       If the internal format of the texture is not a color
  343.       index format then the components are assigned among R, G, B, and A
  344.       according to Table 6.1.  Specifying COLOR_INDEX for format in this case
  345.       will generate the error INVALID_ENUM.  If the internal format of the
  346.       texture is color index then the components are handled in one of two
  347.       ways depending on the value of format.  If format is not COLOR_INDEX,
  348.       the texture's indices are passed through the texture's palette and the
  349.       resulting components are assigned among R, G, B, and A according to
  350.       Table 6.1.  If format is COLOR_INDEX then the data is treated as single
  351.       components and the palette indices are returned.  Components are taken
  352.       starting...
  353.  
  354.     Following the GetTexImage section there should be a new section:
  355.  
  356.       GetColorTableEXT is used to get the current texture
  357.       palette.
  358.     void GetColorTableEXT(enum target, enum format, enum type, void *data);
  359.  
  360.       GetColorTableEXT retrieves the texture palette of the
  361.       texture given by target.  target can be any of the non-proxy targets
  362.       valid for ColorTableEXT.  format and type are interpreted just as for
  363.       ColorTableEXT.  All textures have a palette by default so
  364.       GetColorTableEXT will always be able to return data even if the internal
  365.       format of the texture is not a color index format.
  366.  
  367.       Palette parameters can be retrieved using
  368.     void GetColorTableParameterivEXT(enum target, enum pname, int *params);
  369.     void GetColorTableParameterfvEXT(enum target, enum pname, float *params);
  370.       target specifies the texture being queried and pname
  371.       controls which parameter value is returned.  Data is returned in the
  372.       memory pointed to by params.
  373.  
  374.       Querying COLOR_TABLE_FORMAT_EXT returns the internal
  375.       format requested by the most recent ColorTableEXT call or the default.
  376.       COLOR_TABLE_WIDTH_EXT returns the width of the current palette.
  377.       COLOR_TABLE_RED_SIZE_EXT, COLOR_TABLE_GREEN_SIZE_EXT,
  378.       COLOR_TABLE_BLUE_SIZE_EXT and COLOR_TABLE_ALPHA_SIZE_EXT return the
  379.       actual size of the components used to store the palette data internally,
  380.       not the size requested when the palette was defined.
  381.  
  382.     Table 6.11, "Texture Objects" should have a line appended for
  383.     TEXTURE_INDEX_SIZE_EXT:
  384.  
  385.     TEXTURE_INDEX_SIZE_EXT    n x Z+    GetTexLevelParameter 0    xD texture image i's index resolution    3.8    -
  386.  
  387.  
  388. Revision History
  389.  
  390. Original draft, revision 0.5, December 20, 1995 (drewb) Created
  391.  
  392. Minor revisions and clarifications, revision 0.6, January 2, 1996 (drewb)
  393.     Replaced all request-for-comment blocks with final text
  394.     based on implementation.
  395.  
  396. Minor revisions and clarifications, revision 0.7, Feburary 5, 1996 (drewb)
  397.     Specified the state of the palette color information
  398.     when existing data is replaced by new data.
  399.  
  400.     Clarified behavior of TexPalette on inconsistent textures.
  401.  
  402. Major changes due to ARB review, revision 0.8, March 1, 1996 (drewb)
  403.     Switched from using TexPaletteEXT and GetTexPaletteEXT
  404.     to using SGI's ColorTableEXT routines.  Added ColorSubTableEXT so
  405.     equivalent functionality is available.
  406.  
  407.     Allowed proxies in all targets.
  408.  
  409.     Changed PALETTE?_EXT values to COLOR_INDEX?_EXT.  Added
  410.     support for one and two bit palettes.  Removed PALETTE_INDEX_EXT in
  411.     favor of COLOR_INDEX.
  412.  
  413.     Decoupled palette size from texture data type.  Palette
  414.     size is controlled only by ColorTableEXT.
  415.  
  416. Changes due to ARB review, revision 1.0, May 23, 1997 (drewb)
  417.     Mentioned texture3D.
  418.  
  419.     Defined TEXTURE_INDEX_SIZE_EXT.
  420.  
  421.     Allowed implementations to return an index size of zero to indicate 
  422.     no support for a particular format.
  423.  
  424.     Allowed usage of GL_COLOR_INDEX as a generic format in
  425.     proxy queries for determining an optimal index size for a particular
  426.     texture.
  427.  
  428.     Disallowed CopyTexImage and CopyTexSubImage to paletted
  429.     formats.
  430.  
  431.     Deleted mention of index transfer operations during GetTexImage with 
  432.     paletted formats.
  433.